package com.yanqu.road.server.cmd.banquet.crossBanquet;

import com.yanqu.road.pb.banquet.BanquetProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.banquet.CrossBanquetMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_BANQUET_CROSS_LEAVE, desc = "离开跨服宴会")
public class LeaveBanquetCmd extends AbstractCommand {

	private String banquetId;
	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		BanquetProto.BanquetLeaveReq reqMsg = BanquetProto.BanquetLeaveReq.parseFrom(packet.getBytes());
		banquetId = reqMsg.getBanquetId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = CrossBanquetMgr.removeBanquetScene(player.getUserId(),banquetId);
	}

	@Override
	public void sendData(GamePlayer player) {
		BanquetProto.BanquetLeaveResp.Builder respMsg = BanquetProto.BanquetLeaveResp.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_BANQUET_CROSS_LEAVE, respMsg);
	}
}
